home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 6
/
The Arsenal Files 6 (Arsenal Computer).ISO
/
prg_casm
/
jlvesa11.zip
/
JLVESC00.CPP
< prev
next >
Wrap
Text File
|
1995-11-14
|
1KB
|
88 lines
// This file is part of JLVesa-library
#include "jlvesa.h"
// Draw line on limited area
void JVLine_DrawLimited(int x1,int y1,int x2,int y2,unsigned char color,int xl,int yl,int width,int height)
{
int a,b;
// Switch so that y1<y2
if(y2<y1)
{
a=x1;
b=y1;
x1=x2;
y1=y2;
x2=a;
y2=b;
}
// Limit upper border
if(y2<yl)
return;
if(y1<yl)
{
// y1=yl
x1=(int)(((long)x1*(long)(y2-yl)+(long)x2*(long)(yl-y1))/(long)(y2-y1));
y1=yl;
}
// Limit lower border
if(y1>=yl+height)
return;
if(y2>=yl+height)
{
// y2=yl+height-1
x2=(int)(((long)x1*(long)(y2-yl-height+1)+(long)x2*(long)(yl+height-1-y1))/(long)(y2-y1));
y2=yl+height-1;
}
// Switch so that x1<x2
if(x1>x2)
{
a=x1;
b=y1;
x1=x2;
y1=y2;
x2=a;
y2=b;
}
// Limit left border
if(x2<xl)
return;
if(x1<xl)
{
// x1=xl
y1=(int)(((long)y1*(long)(x2-xl)+(long)y2*(long)(xl-x1))/(long)(x2-x1));
x1=xl;
}
// Limit right border
if(x1>=xl+width)
return;
if(x2>=xl+width)
{
// x2=xl+width-1
y2=(int)(((long)y1*(long)(x2-xl-width+1)+(long)y2*(long)(xl+width-1-x1))/(long)(x2-x1));
x2=xl+width-1;
}
// Draw line
JVLine_Draw(x1,y1,x2,y2,color);
}